============================================================================================================================
Modification Title: Portal System Addon: Stats Bar

Version: 1.0

Author: maluta

Last Updated: 06/16/10

Description:
This modification will provide 3 portal stats displays for portal with added attributes.
This modification will provide classic style, modern style and default style looks (chosen in admin settings).
This modification will provide an on/off control for the portal stats bar (in portal settings).
This modification will provide a most users online ever feature.
This modification will provide a top poster feature.
This modification will provide a member of the day feature.
This modification will provide a today's birthday feature.

Supported Version: XMB 1.9.5 SP1

Updated for 1.9.5 by: WormHole @ XMB Garage

Installation Note: Before adding this modification to your forum, you should back up all files related to this modification.

License Note: This modification is released under the GPL License v3. A copy is provided with this software package.

Author Note:
In order to use this modification you need to have the Portal System v2.4 and Index Stats Barv2.0 installed.
============================================================================================================================
=======
Step 1:
=======

====================================
Go To Administration Panel --> Insert Raw SQL
====================================
========================
Add Code and Submit Changes:
========================

ALTER TABLE `$table_settings` ADD `portalbarstatus` char(3) NOT NULL default 'on';

============================================================================================================================
=======
Step 2:
=======
==================
Edit File: cp_portal.php
==================
==========
Find Code:
==========

        $portalviewon = $portalviewoff = '';
        switch ($SETTINGS['portalview']) {
            case 'on':
                $portalviewon = $selHTML;
                break;
            default:
                $portalviewoff = $selHTML;
                break;
        }

===============
Add Code Below:
===============

        // Portal System Addon: Stats Bar Mod Begin
        $portalbarstatus_on = $portalbarstatus_off = '';
        switch ($SETTINGS['portalbarstatus']) {
            case 'on':
                $portalbarstatus_on = $selHTML;
                break;
            default:
                $portalbarstatus_off = $selHTML;
                break;
        }
        // Portal System Addon: Stats Bar Mod End

==========
Find Code:
==========

        $portalviewnew = ($portalviewnew == 'on') ? 'on' : 'off';

===============
Add Code Below:
===============

        // Portal System Addon: Stats Bar Mod Begin
        $portalbarstatus = ($portalbarstatus == 'on') ? 'on' : 'off';
        // Portal System Addon: Stats Bar Mod End

==========
Find Code:
==========

            portalview='$portalviewnew'

================
Replace Code With:
================

            portalview='$portalviewnew',
            portalbarstatus='$portalbarstatus'

============================================================================================================================
=======
Step 3:
=======
================
Edit File: portal.php
================
==========
Find Code:
==========

loadtemplates(

============
Replace With:
============

loadtemplates(
'portal_statsbar_classic',
'portal_statsbar_modern',
'portal_statsbar_default',

==========
Find Code:
==========

        if ($online['invisible'] != 0) {
            $pre .= '<strike>';
            $suff = '</strike>'.$suff;
            if (!X_ADMIN && $online['username'] != $xmbuser) {
                $num++;
                continue;
            }
        }

===============
Add Code Above:
===============

        // Portal System Addon: Stats Bar Mod Begin
        $query = $db->query("SELECT username FROM $table_members ORDER BY regdate DESC LIMIT 1");
        $lastmember = $db->fetch_array($query);
        $db->free_result($query);

        $query = $db->query("SELECT count(uid) FROM $table_members");
        $members = $db->result($query, 0);
        $db->free_result($query);

        $query = $db->query("SELECT COUNT(tid) FROM $table_threads");
        $threads = $db->result($query, 0);
        $db->free_result($query);

        $query = $db->query("SELECT COUNT(pid) FROM $table_posts");
        $posts = $db->result($query, 0);
        $db->free_result($query);
        $memhtml = '<a href="member.php?action=viewpro&amp;member='.rawurlencode($lastmember['username']).'"><strong>'.$lastmember['username'].'</strong></a>.';
        eval($lang['evalindexstats']);

        if ($SETTINGS['portalbarstatus'] == 'on') {
            require_once('./include/statsbar.inc.php');
        }
        // Portal System Addon: Stats Bar Mod End

============================================================================================================================
=======
Step 4:
=======
=========================
Edit File: include/statsbar.inc.php
=========================
==========
Find Code:
==========

$statsbar = '';
if ($SETTINGS['statsbarview'] == 'classic') {
    eval('$statsbar = "'.template('index_statsbar_classic').'";');
} elseif ($SETTINGS['statsbarview'] == 'modern') {
    eval('$statsbar = "'.template('index_statsbar_modern').'";');
} elseif ($SETTINGS['statsbarview'] == 'default') {
    eval('$statsbar = "'.template('index_statsbar_default').'";');
}

============
Replace with:
============

// Portal System Addon: Stats Bar Mod Begin
$statsbar = $portbar = '';
if ($SETTINGS['statsbarview'] == 'classic') {
    eval('$statsbar = "'.template('index_statsbar_classic').'";');
    eval('$portbar = "'.template('portal_statsbar_classic').'";');
} elseif ($SETTINGS['statsbarview'] == 'modern') {
    eval('$statsbar = "'.template('index_statsbar_modern').'";');
    eval('$portbar = "'.template('portal_statsbar_modern').'";');
} elseif ($SETTINGS['statsbarview'] == 'default') {
    eval('$statsbar = "'.template('index_statsbar_default').'";');
    eval('$portbar = "'.template('portal_statsbar_default').'";');
}
// Portal System Addon: Stats Bar Mod End

============================================================================================================================
=======
Step 5:
=======
========================
Edit File: lang/English.portal.php
========================
============================
Add Code To End Of File Above  ?>
============================

// Portal System Addon: Stats Bar Mod Begin
$lang['portalbarstatus'] = 'Portal Stats Bar Status:<br /><small>The Stats Bar status must be set to "ON" to be shown on portal.</small>';
// Portal System Addon: Stats Bar Mod End

============================================================================================================================
=======
Step 6:
=======
===============================
Go To Administration Panel --> Templates
===============================
==================================
Create New Template: portal_statsbar_classic
==================================
============================
Add Code and Submit Changes:
============================

<br />
<table border="0" cellpadding="0" cellspacing="0" width="$tablewidth" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr class="category">
<td colspan="8"><a href="stats.php"><font color="$cattext"><strong>$lang[statsbarstatsclassic]</strong></font></a></td>
</tr>
<tr style="background-color: $altbg1" class="ctrtablerow">
<td width="4%" rowspan="2"><img src="$imgdir/statsbar.gif" alt="$lang[statsbarstatsclassic]" border="0" /></td>
<td nowrap="nowrap">$lang[statsbarthreadsclassic]</td>
<td nowrap="nowrap">$lang[statsbarpostsclassic]</td>
<td nowrap="nowrap">$lang[statsbarmembersclassic]</td>
<td nowrap="nowrap">$lang[statsbarmostusersclassic]</td>
<td nowrap="nowrap">$lang[statsbarnewmemsclassic]</td>
<td nowrap="nowrap">$lang[statsbartopposterclassic]</td>
<td nowrap="nowrap">$lang[statsbarmemdayclassic]</td>
</tr>
<tr style="background-color: $altbg2" class="ctrtablerow">
<td>$threads</td>
<td>$posts</td>
<td>$members</td>
<td>$mosttext</strong></td>
<td>$statsbarmemhtml</td>
<td>$topposter</td>
<td>$membesthtml2</td>
</tr>
<tr class="tablerow">
<td bgcolor="$altbg2" colspan="8">$lang[statsbarhappybdclassic]&nbsp;$happybday</td>
</tr>
</table>
</td>
</tr>
</table>

============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
==================================
Create New Template: portal_statsbar_default
==================================
========================
Add Code and Submit Changes:
========================

<br />
<table cellspacing="0" cellpadding="0" border="0" width="$tablewidth" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr class="category">
<td><font color="$cattext"><strong>$lang[textstats]:</strong></font></td>
</tr>
<tr class="tablerow" bgcolor="$altbg2">
<td align="left" valign="top">$lang[indexstats]<br />$lang[stats4] $statsbarmemhtml<br />$lang[statsbartext12]$portmosttext$lang[statsbartext7]</td>
</tr>
</table>
</td>
</tr>
</table>

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
==================================
Create New Template: portal_statsbar_modern
==================================
========================
Add Code and Submit Changes:
========================

<br />
<table border="0" cellpadding="0" cellspacing="0" width="$tablewidth" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
<tr>
<td class="tablerow" colspan="2" width="100%">
<table cellspacing="1" cellpadding="$tablespace" border="0" width="100%" align="center">
<tr class="category">
<td colspan="6"><a href="stats.php"><strong><font color="$cattext">$lang[statsbarstatsclassic]</font></strong></a></td>
</tr>
<tr>
<td bgcolor="$altbg1" align="center" class="tablerow" width="4%"><img src="$imgdir/statsbar.gif" alt="$lang[statsbarstatsclassic]" border="0" /></td>
<td bgcolor="$altbg2" colspan="5" class="mediumtxt">
$lang[statsbartext1]<strong>$members</strong>$lang[statsbartext2]
<br />
$lang[statsbartext1]<strong>$threads</strong>$lang[statsbartext3]
<br />
$lang[statsbartext4]<strong>$posts</strong>$lang[statsbartext5]
<br />
$lang[statsbartext6]$statsbarmemhtml.
<br />
$lang[statsbartext8]$happybday
<br />
$lang[statsbartext9]$topposter2$lang[statsbartext10]<strong>$topposts2</strong>$lang[statsbartext5]
<br />
$lang[statsbartext11]$membesthtml$lang[statsbartext10]<strong>$bm[authorpost]</strong>$lang[statsbartext5]
<br />
$lang[statsbartext12]$mosttext$lang[statsbartext7]
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>

============================================================================================================================
=======
Step 9:
=======
===============================
Go To Administration Panel --> Templates
===============================
=====================
Edit Template: portal_home
=====================
=======================================
Add Code To End Of Template and Submit Changes:
=======================================

$portbar

============================================================================================================================
=======
Step 10:
=======
===============================
Go To Administration Panel --> Templates
===============================
============================
Edit Template: padmin_admin_settings
============================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="50%">$lang[portaltitle]</td>
<td bgcolor="$THEME[altbg2]"><input type="text" name="portaltitlenew" value="$portaltitle" size="25" /></td>
</tr>

===============
Add Code Below:
===============

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="50%">$lang[portalbarstatus]</td>
<td bgcolor="$THEME[altbg2]">
<select size="1" name="portal_portalbar">
<option value="on" $portalbarstatus_on>$lang[texton]</option>
<option value="off" $portalbarstatus_off>$lang[textoff]</option>
</select></td>
</tr>

============================================================================================================================
Enjoy!